/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package edu.ortn.wildbots.commands;

import java.util.Vector;

/**
 *
 * @author Tag
 */
public class CameraControl extends CommandBase {
    
    private Vector commands;
    
    public CameraControl() {
        requires(camMount);
        commands = new Vector();
    }

    // Called just before this Command runs the first time
    protected void initialize() {
    }

    // Called repeatedly when this Command is scheduled to run
    protected void execute() {
       int direction = ((Integer)commands.firstElement()).intValue();
       if (direction == 1) {
           camMount.tiltUp();
       } else if (direction == 2) {
           camMount.tiltDown();
       } else if (direction == 3) {
           camMount.panLeft();
       } else if (direction == 4) {
           camMount.panRight();
       } else if (direction == 5) {
           camMount.setCenter();
       }
       commands.removeAllElements();
    }
    
    public void moveLeft() {
        commands.addElement(Integer.valueOf(3));
    }
    
    public void moveRight() {
        commands.addElement(Integer.valueOf(4));
    }
    
    public void moveUp() {
        commands.addElement(Integer.valueOf(1));
    }
    
    public void moveDown() {
        commands.addElement(Integer.valueOf(2));
    }
    
    public void setCenter() {
        commands.addElement(Integer.valueOf(5));
    }
    
    public void setSpeed(double speed) {
        camMount.setSpeed(speed);
    }
    
    public static double getVerticleAngle(){
        return camMount.tilt.getAngle();
    }

    public static double getHorizontalAngle() {
        return camMount.pan.getAngle();
    }
    // Make this return true when this Command no longer needs to run execute()
    protected boolean isFinished() {
        return false;
    }

    // Called once after isFinished returns true
    protected void end() {
    }

    // Called when another command which requires one or more of the same
    // subsystems is scheduled to run
    protected void interrupted() {
    }
}
